﻿//49.字母异位词分组（https://leetcode.cn/problems/group-anagrams/）
class Solution
{
public:
    vector<vector<string>> groupAnagrams(vector<string>& strs)
    {
        vector<vector<string>> ret;
        unordered_map<string, vector<string>> hash;
        for (auto& s : strs)
        {
            string tmp = s;
            sort(tmp.begin(), tmp.end());
            hash[tmp].push_back(s);
        }

        for (auto& [x, y] : hash)
        {
            ret.push_back(y);
        }

        return ret;
    }
};